/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author shinji
 */
@Entity
@Table(name = "Role_Rights")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "RoleRights.findAll", query = "SELECT r FROM RoleRights r"),
    @NamedQuery(name = "RoleRights.findByIDRights", query = "SELECT r FROM RoleRights r WHERE r.roleRightsPK.iDRights = :iDRights"),
    @NamedQuery(name = "RoleRights.findByIDRole", query = "SELECT r FROM RoleRights r WHERE r.roleRightsPK.iDRole = :iDRole"),
    @NamedQuery(name = "RoleRights.findByAgree", query = "SELECT r FROM RoleRights r WHERE r.agree = :agree")})
public class RoleRights implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected RoleRightsPK roleRightsPK;
    @Column(name = "Agree")
    private Boolean agree;
    @JoinColumn(name = "ID_Role", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Role role;
    @JoinColumn(name = "ID_Rights", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Rights rights;

    public RoleRights() {
    }

    public RoleRights(RoleRightsPK roleRightsPK) {
        this.roleRightsPK = roleRightsPK;
    }

    public RoleRights(int iDRights, int iDRole) {
        this.roleRightsPK = new RoleRightsPK(iDRights, iDRole);
    }

    public RoleRightsPK getRoleRightsPK() {
        return roleRightsPK;
    }

    public void setRoleRightsPK(RoleRightsPK roleRightsPK) {
        this.roleRightsPK = roleRightsPK;
    }

    public Boolean getAgree() {
        return agree;
    }

    public void setAgree(Boolean agree) {
        this.agree = agree;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    public Rights getRights() {
        return rights;
    }

    public void setRights(Rights rights) {
        this.rights = rights;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (roleRightsPK != null ? roleRightsPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RoleRights)) {
            return false;
        }
        RoleRights other = (RoleRights) object;
        if ((this.roleRightsPK == null && other.roleRightsPK != null) || (this.roleRightsPK != null && !this.roleRightsPK.equals(other.roleRightsPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.RoleRights[ roleRightsPK=" + roleRightsPK + " ]";
    }
    
}
